package p.ithorns.tools.translator.sdk.handler;


import com.google.auto.service.AutoService;
import p.ithorns.tools.translator.annotation.IDict;
import p.ithorns.tools.translator.annotation.Translator;
import p.ithorns.tools.translator.annotation.field.EnumField;

import java.io.Serializable;


/**
 * EnumTransformer
 * 枚举
 *
 * @author R
 */
@AutoService(Translator.class)
public class EnumTranslator<T extends Serializable> implements Translator<T, EnumField> {

    @Override
    @SuppressWarnings("unchecked")
    public String translate(EnumField annotation, T enumCode) {
        return IDict.getTextByCode((Class<? extends IDict<T>>) annotation.type(), enumCode);
    }

}
